<?php

$sitesettings = M('config');
$restest = $sitesettings -> select();
$set = array();
foreach($restest as $key => $value){
    $set[ $restest[$key]['key'] ] = $value['value'];
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keywords" content="<?php echo $set['keywords']; ?>">
    <meta name="info" content="<?php echo $set['siteinfo']; ?>">
    <style>
        #chat{
            display:none;
            width:280px;
            /*padding:10px;*/
            background-color: rgba(255, 255, 255, 1);
            box-shadow: -1px 0px 3px #ccc;
            position: fixed;
            right:0px;
            top:60px;
            bottom: 0px;
            z-index: 1001;
            overflow-y: scroll;
        }
        #chat ul{
            /*background-color: red;*/
            margin: 0px;
        }
        #chat ul li a{
            padding: 15px 10px !important;
            width: 100%;
            display: inline-block;
            border-bottom: 1px solid #EBEBEB !important;
            font-size: 12px;
            list-style: none;
            transition: all .3s;
        }
        #chat ul li a:hover{
            background-color: #F7F8F9;
            color: #2E2E2E;
        }
        #chat ul li a .photo{
            display: inline-block;
            border-radius: 2px 2px 2px 2px;
            float: left;
            height: 50px;
            margin-right: 10px;
            width: 50px;
            background-size:cover;
            background-position:center;
        }
        #chat ul li a .friend-signature {
            display: block !important;
            font-size: 14px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        #chat ul li a .subject .from {
            font-size: 16px;
            font-weight: 600;
            line-height: 28px;
        }
        #chat ul li a .subject .friend-online {
            font-size: 10px;
            /*font-style: italic;*/
            font-weight: bold;
            position: absolute;
            right: 15px;
            color:white;
        }

        #chat-block{
            display: none;
            right:300px;
            bottom: 1px;
            position: fixed;
            z-index: 1003;
        }
        #chat-block>.panel{
            box-shadow: 0px 0px 20px #ccc;
            background-image: url(__PUBLIC__/Resource/chatbg.jpg);
            background-size: cover;
            background-position:0 -100px;
        }
        #chat-block .panel-heading{
            height:50px;
            line-height: 30px;
            background-color: rgba(255,255,255, 0.9)!important;
        }
        #chat-block .panel-main{
            height:350px;
            overflow-y: scroll;
            background-color: rgba(255,255,255,0.3);
        }
        #chat-block .panel-input{
            border-top: 1px solid #ddd;
            padding: 10px;
            background-color: white;
        }
        #chat-block .panel-input textarea{
            outline:none;
            border:none;
            resize:none;
        }
        #chat-block .photo{
            width:60px;
            height:60px;
            overflow: hidden;
            /*border: 2px solid #fff;*/
            background-color: white;
            background-size:cover;
            background-position: center;
            /*-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, .2);
            box-shadow: 0px 0px 10px rgba(0, 0, 0, .2);*/
        }

        #chat-block .panel-footer{
            text-align: right;
            background-color: rgba(255,255,255, 0.9)!important;
        }

        #chat-demo{
            display: none;
        }
        #chat-demo .time{
            width:90px;
        }
        #chat-demo .content{
            color:#555;
            min-height:18px;
        }
        #chat-demo .activity-desk>.panel{
            word-wrap:break-word;
            word-break:break-all;
            background-color: rgba(255,255,255,0.95);
        }
        .activity .activity-desk .arrow{
            border-right: 8px solid rgba(255,255,255,0.95) !important;
        }
        .activity-desk .arrow-alt {
            border-left: 8px solid rgba(255,255,255,0.95) !important;
        }
        #friend-demo{
            display: none;
        }

        /*审查信息的样式*/
        #header_notification_bar .label{
            margin-right: 6px;
        }

        #checkdetail th, #checkdetail tr,#checkdetail td{
            text-align: center;
        }
        .closeX{
            cursor:pointer;
        }

        #popdiv  .popover-t{
            padding: 8px 14px;
            margin: 0;
            font-size: 14px;
            font-weight: normal;
            line-height: 18px;
            /*background-color: #f7f7f7;*/
            border-bottom: 1px solid #ebebeb;
            border-radius: 5px 5px 0 0;
            color:white;
            text-align: center;
        }
        #popdiv  .popover-c{
            padding: 9px 14px;
            color:white;
        }

        #friend-request{
            width:10px;
            height:10px;
            background-color: rgb(255, 41, 118);
            border-radius: 50%;
            display: none;
            /*float: right;*/
            margin-top: 5px;
            margin-left:10px;
        }
    </style>
    <title>{$test}<?php echo '-'.$set['sitename'] ?></title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/Theme/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/Theme/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="__PUBLIC__/Theme/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.css" rel="stylesheet" type="text/css" media="screen"/>
    <link rel="stylesheet" href="__PUBLIC__/Theme/css/owl.carousel.css" type="text/css">
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/Theme/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme/css/style-responsive.css" rel="stylesheet" />
    <script src="__PUBLIC__/Theme/js/jquery.js"></script>
    <script src="__PUBLIC__/Theme/js/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Alert/css/dialog.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Alert/css/dialog-alex.css" />
    <script src="__PUBLIC__/Alert/js/modernizr.custom.js"></script>
    <script src="__PUBLIC__/Holder/holder.js"></script>
    <link rel="shortcut icon" href="__PUBLIC__<?php echo $set['icoimg'] ?>">
    <block name='topscript'></block>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Theme/assets/gritter/css/jquery.gritter.css" />


</head>

<body>
    <block name='body'>


        <!-- 为登录页面准备的块标签 S -->
        <section id="container" class="">
            <!-- 好友模板 -->
            <li class="chat-friend" id="friend-demo" user-id="">
                <a href="javascript:void(0);">
                    <span class="photo"></span>
                    <span class="subject">
                        <span class="from friend-name"></span>
                        <span class="friend-online label"></span>
                    </span>
                    <span class="friend-signature"></span>
                </a>
            </li>

            <div id="chat">
                <!-- 公众号 -->
                <ul class="ul-public">
                    <li id="turing" user-id="0">
                        <a href="javascript:void(0);">
                            <span class="photo" src="__PUBLIC__/Resource/xiaonan.jpeg" style="background-image: url(__PUBLIC__/Resource/xiaonan.jpeg);"></span>
                            <span class="subject">
                                <span class="from friend-name">小囡</span>
                                <span class="friend-online label label-success">本宝宝一直都在线</span>
                            </span>
                            <span class="friend-signature">(*￣ω￣*)</span>
                        </a>
                    </li>
                </ul>
                <!-- 好友 -->
                <ul class="ul-firend"></ul>
            </div>
            <!-- 聊天框模板 -->
            <div class="activity" id="chat-demo">
                <span class="photo"></span>
                <div class="activity-desk">
                    <div class="panel">
                        <div class="panel-body">
                            <div class="arrow"></div> <i class=" icon-time"></i>
                            <h4 class="time"></h4>
                            <p class="content"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-lg-6" id="chat-block" user-id="">
                <section class="panel">
                    <header class="panel-heading">
                        <span></span>
                        <button type="button" class="btn btn-sm btn-danger pull-right btn-close">X</button>
                    </header>
                    <div class="panel-body panel-main profile-activity">
                        <h5 class="pull-right">2016-05-23</h5>
                    </div>
                    <div class="panel-input">
                        <textarea id="chat-input" rows="2" cols="102"></textarea>
                    </div>
                    <div class="panel-footer">
                        <span class="tips"></span>
                        <button type="button" class="btn btn-sm btn-primary" id="btn-shake" style="float:left"><i class="glyphicon glyphicon-flash"></i> 窗口抖动</button>
                        <button type="button" class="btn btn-sm btn-primary btn-close">关闭</button>
                        <button type="button" class="btn btn-sm btn-primary" id="btn-send">发送</button>
                    </div>
                </section>
            </div>
            <script type="text/javascript">
                    $(function(){
                        //侦听消息定时器
                        var listenDataTimer=null;
                        //侦听消息
                        function listenData(){
                            $.post("{:U('Home/Friend/getNewFriend')}",{},function(data){
                                // console.log(data);
                                if(data>0){
                                    $('#friend-request').css('display','inline-block');
                                }else{
                                    $('#friend-request').css('display','none');
                                }
                            },'JSON');
                        }
                        listenData();
                        var listenDataTimer=setInterval(listenData,5000);

                        //获取好友列表
                        function getFriendList(){
                            $.get("{:U('Home/Chat/getFriendList')}",{},function(data){
                                $('#chat .ul-firend').empty();
                                for(var i in data){
                                    var friend=$('#friend-demo').clone(true);
                                    friend.attr('user-id',data[i]['user_id']);
                                    friend.find('.friend-name').html(data[i]['nickname']);
                                    if(data[i]['online']==1){
                                        friend.find('.friend-online').html('在线');
                                        friend.find('.friend-online').addClass('label-success');
                                    }else{
                                        friend.find('.friend-online').html('离线');
                                        friend.find('.friend-online').addClass('label-default');
                                    }
                                    friend.find('.friend-signature').html(data[i]['signature']);
                                    friend.find('.photo').attr('src',"__PUBLIC__"+data[i]['photo']);
                                    friend.find('.photo').css('background-image',"url(__PUBLIC__"+data[i]['photo']+')');
                                    friend.show();
                                    $('#chat .ul-firend').append(friend);
                                }
                            },'JSON');
                        }

                        //时间戳转换成四位时间10:10:00
                        function userTime(uTime){
                            var myDate = new Date(uTime*1000);
                            var hours = myDate.getHours();
                            var minutes = myDate.getMinutes();
                            var second = myDate.getSeconds();
                            return hours + ':' + minutes + ':' + second;
                        }

                        //获取好友列表定时器
                        var getFriendTime=null;

                        //会话
                        $('#btn-chat').click(function(){
                            if($('#chat').css('display')=='none'){
                                getFriendList();
                                if(getFriendTime==null){
                                    getFriendTime=setInterval(getFriendList,5000);
                                }
                            }else{
                                clearInterval(getFriendTime);
                                $('.btn-close').trigger('click');
                            }
                            $('#chat').fadeToggle();
                        });

                        //定义获取消息的定时器（进入聊天时开启，退出聊天时关闭）
                        var getChatTimer=null;
                        //获取消息时间间隔
                        var getChatInterval=2000;
                        //设置最后一条消息的id
                        var chatLastId=0;

                        //点击好友聊天
                        $('.chat-friend').click(function(){
                            //隐藏抖动按钮
                            $('#btn-shake').show();
                            //获取好友id
                            var user_id=$(this).attr('user-id');
                            //获取当前聊天好友id
                            var cur_id=$('#chat-block').attr('user-id');
                            //验证是否切换好友聊天，是则初始化数据
                            if(user_id!=cur_id){
                                clearInterval(getChatTimer);
                                getChatTimer=null;
                                //初始化最后一条消息的id
                                chatLastId=0;
                                //清空初始化
                                $('.panel-main').empty();
                                //获取好友信息
                                var nickname=$(this).find('.friend-name').html();
                                var photo=$(this).find('.photo').attr('src');
                                $('#chat-block').attr('user-id',user_id);
                                $('#chat-block .panel-heading span').html(nickname);
                            }
                            if(getChatTimer==null){
                                $('#chat-block').fadeIn();
                                $('#chat-input').focus();

                                var j=0;
                                var iniChatMsg=function(){
                                    //获取聊天记录
                                    $.ajax({
                                        type:'get',
                                        url:"{:U('Home/Chat/getChatHistory')}",
                                        data:{id:user_id,lastid:chatLastId},
                                        dataType:'json',
                                        async:true,
                                        success:function(data){
                                            if(data.status==1){
                                                var chatInfo=data.content;
                                                //设置聊天记录
                                                for(var i in chatInfo){
                                                    if(chatInfo[i]['chat_id']>chatLastId){
                                                        var demo=$('#chat-demo').clone();
                                                        //好友的消息
                                                        if(chatInfo[i]['user_id_a']==user_id){
                                                            demo.find('.photo').css('background-image','url('+photo+')');
                                                            if(chatInfo[i]['content']=='[抖动]'){
                                                                chatInfo[i]['content']='<div style ="color:rgb(132, 220, 153);">您的好友给您发送了一个窗口抖动！</div>';
                                                            }
                                                        }else{
                                                            if(chatInfo[i]['content']=='[抖动]'){
                                                                chatInfo[i]['content']='<div style ="color:rgb(132, 220, 153);">您发送了一个窗口抖动！</div>';
                                                            }
                                                            //自己的消息
                                                            demo.find('.photo').css('background-image',"url(__PUBLIC__{$Think.session.home.photo})");
                                                            demo.addClass('alt');
                                                            demo.find('.arrow').attr('class','arrow-alt');
                                                        }
                                                        var createTime = userTime(chatInfo[i]['time']);
                                                        demo.find('.time').html(createTime);
                                                        demo.find('.content').html(chatInfo[i]['content']);
                                                        $('.panel-main').append(demo);
                                                        demo.fadeIn();
                                                        //最后一条消息id
                                                        j=chatInfo[i]['chat_id'];

                                                        //置底
                                                        $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                                                    }
                                                }
                                                chatLastId=j;
                                            }
                                        }
                                    });
                                }

                                var getChatMsg=function(){
                                    //获取聊天记录
                                    $.ajax({
                                        type:'get',
                                        url:"{:U('Home/Chat/getChatHistory')}",
                                        data:{id:user_id,lastid:chatLastId},
                                        dataType:'json',
                                        async:true,
                                        success:function(data){
                                            if(data.status==1){
                                                var chatInfo=data.content;
                                                var last;
                                                var f=false;
                                                //设置聊天记录
                                                for(var i in chatInfo){
                                                    if(chatInfo[i]['chat_id']>chatLastId){
                                                        //好友的消息
                                                        if(chatInfo[i]['user_id_a']==user_id){
                                                            if(chatInfo[i]['content']=='[抖动]'){
                                                                chatInfo[i]['content']='<div style ="color:rgb(132, 220, 153);">您的好友给您发送了一个窗口抖动！</div>';
                                                                f=true;
                                                            }
                                                            //最后一条消息id
                                                            last=chatInfo[i]['chat_id'];
                                                            var demo=$('#chat-demo').clone();
                                                            demo.find('.photo').css('background-image','url('+photo+')');
                                                            var createTime = userTime(chatInfo[i]['time']);
                                                            demo.find('.time').html(createTime);
                                                            demo.find('.content').html(chatInfo[i]['content']);
                                                            $('.panel-main').append(demo);
                                                            demo.fadeIn();

                                                            //置底
                                                            $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                                                        }
                                                    }
                                                }
                                                //如果好友的消息是最新
                                                if(last>chatLastId){
                                                    chatLastId=last;
                                                }
                                                if(f){
                                                    $('#chat-block').animate({'right':'306px'},30);
                                                    $('#chat-block').animate({'right':'294px'},30);
                                                    $('#chat-block').animate({'right':'306px'},30);
                                                    $('#chat-block').animate({'right':'294px'},30);
                                                    $('#chat-block').animate({'right':'306px'},30);
                                                    $('#chat-block').animate({'right':'294px'},30);
                                                    $('#chat-block').animate({'right':'306px'},30);
                                                    $('#chat-block').animate({'right':'294px'},30);
                                                }
                                            }
                                        }
                                    });
                                }
                                iniChatMsg();
                                getChatTimer=setInterval(getChatMsg,getChatInterval);
                            }
                        })

                        //图灵聊天
                        $('#turing').click(function(){
                            //隐藏抖动按钮
                            $('#btn-shake').hide();
                            //获取好友id
                            var user_id=$(this).attr('user-id');
                            //获取当前聊天好友id
                            var cur_id=$('#chat-block').attr('user-id');
                            //验证是否切换好友聊天，是则初始化数据
                            if(user_id!=cur_id){
                                clearInterval(getChatTimer);
                                getChatTimer=null;
                                //初始化最后一条消息的id
                                chatLastId=0;
                                //清空初始化
                                var nickname=$(this).find('.friend-name').html();
                                var photo=$(this).find('.photo').attr('src');
                                $('.panel-main').empty();
                                $('#chat-block').attr('user-id',user_id);
                                $('#chat-block .panel-heading span').html(nickname);
                                var demo=$('#chat-demo').clone();
                                demo.find('.photo').css('background-image','url('+photo+')');
                                //获取时间
                                var dt=new Date();
                                var miao=dt.getSeconds();
                                var fen=dt.getMinutes();
                                if(miao<10){
                                    miao='0'+miao;
                                }
                                if(fen<10){
                                    fen='0'+fen;
                                }
                                var createTime = dt.getHours() + ':' + fen + ':' + miao;
                                demo.find('.time').html(createTime);
                                demo.find('.content').html('和小囡来聊聊吧~');
                                $('.panel-main').append(demo);
                                demo.fadeIn();
                                //置底
                                $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                                $('#chat-input').focus();
                            }
                            $('#chat-block').fadeIn();
                            $('#chat-input').focus();
                        })


                        //聊天滚动条置底
                        $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);

                        //输入框按回车
                        $('.panel-input').keydown(function(e){
                            if(e.keyCode==13){
                                $('#btn-send').trigger('click');
                                return false;
                            }
                        })


                        //发送窗口抖动
                        $('#btn-shake').click(function(){
                            $('#btn-shake').addClass('disabled');
                            setTimeout(function(){
                                $('#btn-shake').removeClass('disabled');
                            },3000);

                            $('#chat-block').animate({'right':'306px'},30);
                            $('#chat-block').animate({'right':'294px'},30);
                            $('#chat-block').animate({'right':'306px'},30);
                            $('#chat-block').animate({'right':'294px'},30);
                            $('#chat-block').animate({'right':'306px'},30);
                            $('#chat-block').animate({'right':'294px'},30);
                            $('#chat-block').animate({'right':'306px'},30);
                            $('#chat-block').animate({'right':'294px'},30);

                            //将消息添加到消息列表中
                            var demo=$('#chat-demo').clone();
                            demo.addClass('alt');
                            demo.find('.arrow').attr('class','arrow-alt');
                            demo.find('.photo').css('background-image',"url(__PUBLIC__{$Think.session.home.photo})");

                            var dt=new Date();
                            var miao=dt.getSeconds();
                            var fen=dt.getMinutes();
                            if(miao<10){
                                miao='0'+miao;
                            }
                            if(fen<10){
                                fen='0'+fen;
                            }
                            var createTime = dt.getHours() + ':' + fen + ':' + miao;

                            demo.find('.time').html(createTime);
                            demo.find('.content').html('<div style ="color:rgb(132, 220, 153);">您发送了一个窗口抖动！</div>');
                            $('.panel-main').append(demo);
                            demo.fadeIn();
                            //置底
                            $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                            $('#chat-input').focus();

                            //发送消息
                            var friend_id=$('#chat-block').attr('user-id');
                            if(friend_id!=0){
                                //给普通朋友发消息
                                $.post("{:U('Home/Chat/sendChatMessages')}",{id:friend_id,content:'[抖动]'},function(data){
                                    if(data.status==1){
                                        chatLastId=data.id;
                                    }else{
                                        alert('发送失败！');
                                    }
                                },'JSON');
                            }
                        });


                        var oldSendTime=0;//最后一次发送时间
                        var hideTime=null;
                        //发送
                        $('#btn-send').click(function(){
                            var dt = new Date();
                            var newSendTime=dt.getTime();//最新一次发送时间
                            if(newSendTime-oldSendTime<1500){
                                $('.tips').html('你发太快了！');
                                if(hideTime==null){
                                    hideTime=setTimeout(function(){
                                        $('.tips').html('');
                                        hideTime=null;
                                    },2000);
                                }
                                return false;
                            }

                            var content=$('#chat-input').val();
                            //清空输入框
                            $('#chat-input').val('');

                            //将消息添加到消息列表中
                            var demo=$('#chat-demo').clone();
                            demo.addClass('alt');
                            demo.find('.arrow').attr('class','arrow-alt');
                            demo.find('.photo').css('background-image',"url(__PUBLIC__{$Think.session.home.photo})");

                            var miao=dt.getSeconds();
                            var fen=dt.getMinutes();
                            if(miao<10){
                                miao='0'+miao;
                            }
                            if(fen<10){
                                fen='0'+fen;
                            }
                            var createTime = dt.getHours() + ':' + fen + ':' + miao;

                            demo.find('.time').html(createTime);
                            demo.find('.content').html(content);
                            $('.panel-main').append(demo);
                            demo.fadeIn();
                            //置底
                            $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                            $('#chat-input').focus();

                            //发送消息
                            var friend_id=$('#chat-block').attr('user-id');
                            if(friend_id!=0){
                                //给普通朋友发消息
                                $.post("{:U('Home/Chat/sendChatMessages')}",{id:friend_id,content:content},function(data){
                                    if(data.status==1){
                                        chatLastId=data.id;
                                    }else{
                                        alert('发送失败！');
                                    }
                                },'JSON');
                            }else{
                                setTimeout(function(){
                                    //给图灵机器人发消息
                                    $.ajax({
                                        type:'post',
                                        url:"http://www.tuling123.com/openapi/api",
                                        data:{
                                            key:'ccec34bad31d6607d470c7aa525a9ffd',
                                            info:content,
                                            userid:{$Think.session.home.uid}
                                        },
                                        dataType:'json',
                                        async:true,
                                        success:function(data){
                                            // console.log(data);
                                            if($('#chat-block').attr('user-id')==0){
                                                var str='';
                                                switch(data.code){
                                                    case 100000://文字
                                                        str='';
                                                        break;
                                                    case 200000://链接
                                                        str='<a href="'+data.url+'" target="_blank">'+data.url+'</a>';
                                                        break;
                                                    case 302000://新闻
                                                        for(var i=0;i<data['list'].length;i++){
                                                            str+='<hr />';
                                                            str+='<a href="'+data['list'][i].detailurl+'" target="_blank">【'+data['list'][i].source+'】'+data['list'][i].article+'</a>';
                                                        }
                                                        break;
                                                    case 308000://菜谱
                                                        for(var i=0;i<data['list'].length;i++){
                                                            str+='<hr />';
                                                            str+='<a href="'+data['list'][i].detailurl+'" target="_blank">'+data['list'][i].name+'</a><br />';
                                                            str+=data['list'][i].info;
                                                        }
                                                        break;
                                                }
                                                var photo=$('#turing').find('.photo').attr('src');
                                                var demo=$('#chat-demo').clone();
                                                demo.find('.photo').css('background-image','url('+photo+')');

                                                //获取时间
                                                var dt=new Date();
                                                var miao=dt.getSeconds();
                                                var fen=dt.getMinutes();
                                                if(miao<10){
                                                    miao='0'+miao;
                                                }
                                                if(fen<10){
                                                    fen='0'+fen;
                                                }
                                                var createTime = dt.getHours() + ':' + fen + ':' + miao;

                                                demo.find('.time').html(createTime);
                                                demo.find('.content').html(data.text+'<br />'+str);
                                                $('.panel-main').append(demo);
                                                demo.fadeIn();
                                                //置底
                                                $('.panel-main').scrollTop($('.panel-main')[0].scrollHeight);
                                                $('#chat-input').focus();
                                            }
                                        }
                                    });
                                },1000);
                            }

                            //更新上一次时间
                            oldSendTime=newSendTime;
                        })

                        //关闭
                        $('.btn-close').click(function(){
                            chatLastId=0;
                            $('#chat-block').attr('user-id','');
                            clearInterval(getChatTimer);
                            getChatTimer=null;
                            $('#chat-block').fadeOut();
                        })
                    });
                </script>
            <!--顶部 S-->
            <header class="header white-bg">
                <div class="sidebar-toggle-box">
                    <div data-original-title="点击显示/隐藏 左侧菜单" data-placement="right" class="icon-reorder tooltips"></div>
                </div>
                <!--logo start-->
                <a href="#" class="logo">
                    P
                    <span>
                        <SUP>6</SUP>
                    </span>
                </a>
                <!--logo end-->

                <div class="nav notify-row" id="top_menu">
                    <!--  顶部提示信息 S 暂时隐藏 -->
                    <ul class="nav top-menu" style="">
                        <!-- settings start -->
                        <li class="dropdown" style="">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <i class="icon-cloud"></i>
                                <!-- <i class="icon-umbrella"></i> -->
                                <span class="badge bg-success"></span>
                            </a>
                            <ul class="dropdown-menu extended tasks-bar" style="">
                                <div class="notify-arrow notify-arrow-green"></div>
                                <li>
                                    <p class="green">上海天气预报</p>
                                </li>

                                <li>
                                    <a href="" target="" style="cursor:default;padding-top:10px!important;">
                                            <span class="from">
                                                <if condition="$weather['daily_forecast'][0]['cond'][txt_d] eq $weather['daily_forecast'][0]['cond'][txt_n]">
                                                    {$weather['daily_forecast'][0]['cond'][txt_d]}
                                                <else />
                                                    {$weather['daily_forecast'][0]['cond'][txt_d]}转{$weather['daily_forecast'][0]['cond'][txt_n]}
                                                </if>
                                            </span>

                                       <span class="message" style="margin-left:10px;font-weight:bold;">
                                        <if condition="$weather['daily_forecast'][0]['tmp']['min'] eq $weather['daily_forecast'][0]['tmp']['max']">
                                            {$weather['daily_forecast'][0]['tmp']['min']}℃
                                        <else />
                                            {$weather['daily_forecast'][0]['tmp']['min']}&sim;{$weather['daily_forecast'][0]['tmp']['max']}℃
                                        </if>
                                       </span>
                                        <span class="message" style="display:inline-block!important;width:20px!important;height:20px!important;background:url('http://files.heweather.com/cond_icon/{$weather['now']['cond']['code']}.png')!important;background-size:20px 20px!important;margin-left:20px;"></span>
                                    </a>

                                </li>

                                <li>
                                    <a href="" target="" style="cursor:default">
                                            <span class="message">
                                               当前温度: <b>{$weather['now']['tmp']}℃</b>
                                            </span>
                                            <span class="message" style="margin-left:10px;font-weight:bold;">
                                                {$weather['now']['cond']['txt']}℃
                                            </span>

                                    </a>
                                </li>

                                <li>
                                    <a href="" target="" style="cursor:default">
                                            <span class="message" >
                                               相对湿度:  <b>{$weather['daily_forecast'][0]['hum']}%  </b>
                                            </span>
                                            <span class="message" style="margin-left:10px;">
                                              降雨概率: <b>{$weather['daily_forecast'][0]['pop']}%</b>
                                            </span>

                                    </a>
                                </li>

                                <li>
                                    <a href="" target="" style="cursor:default">
                                            <span class="message">
                                               风力: {$weather['daily_forecast'][0]['wind']['dir']}{$weather['daily_forecast'][0]['wind']['sc']}
                                            </span>
                                            <span class="message" style="margin-left:10px;font-weight:bold;">
                                               {$weather['aqi']['city']['qlty']}
                                            </span>
                                    </a>
                                </li>

                           <!--      <li>
                                    <a href="" target="">
                                            <span class="message">

                                            </span>

                                    </a>
                                </li> -->

                                <li>
                                    <a href="" target="" style="white-space:normal;cursor:default">
                                            <span class="message">生活指数: {$weather['suggestion']['drsg']['txt']}
                                            </span>
                                    </a>
                                </li>

                            </ul>
                        </li>
                        <!-- settings end -->
                        <!-- inbox dropdown start-->
                        <li id="header_inbox_bar" class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <!-- <i class="icon-bullhorn"></i> -->
                                <i class="icon-volume-up"></i>
                                <span class="badge bg-important"></span>
                            </a>
                            <ul class="dropdown-menu extended inbox">
                                <div class="notify-arrow notify-arrow-red"></div>
                                <li>
                                    <p class="red">你有5条新闻</p>
                                </li>
                                <foreach name="news_list" item="voo">
                                <li>
                                    <a href="{$voo['url']}" target="_blank">
                                        <span class="photo">
                                            <img data-src="holder.js/35x35/auto/vine" class="img-circle" width="34px" height="34px" src="{$voo['image_url']}"></span>
                                        <!-- <span class="subject"> -->
                                            <span class="from">{$voo['abstract']|substr=0,33}</span>

                                       <span class="message">{$voo['title']|substr=0,42}</span>
                                    </a>
                                </li>
                            </foreach>
                            </ul>
                        </li>
                        <!-- inbox dropdown end -->
                        <!-- notification dropdown start-->
                        <li id="header_notification_bar" class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#" >

                                <i class="icon-bell-alt"></i>
                                <span class="badge bg-warning" id="tchknum">{$check_num}</span>
                            </a>
                            <ul class="dropdown-menu extended notification">
                                <div class="notify-arrow notify-arrow-yellow"></div>
                                <li>
                                    <p class="yellow">你有<span id="chknum">{$check_num|default="0"}</span>个新的通知</p>
                                </li>

                                <foreach name="check" item="vo" key="k">
                                <if condition="$vo['cont_type'] eq 1">
                                    <li>
                                        <a href="#" class="check_i" cid="{$vo['c_id']}">
                                            <span class="label label-danger">
                                                <i class="icon-credit-card"></i>
                                            </span>
                                            [系统# 信息->警告]
                                            <span class="small italic">{$vo['diff']}</span>
                                        </a>
                                    </li>
                                <else />
                                    <li>
                                        <!-- <a href="#" id="add-without-image" class=""> -->
                                        <a href="#" class="check_i" cid="{$vo['c_id']}">
                                            <span class="label label-warning">
                                                <i class="icon-picture"></i>
                                            </span>
                                            [系统# 图片->警告]
                                            <span class="small italic">{$vo['diff']}</span>
                                        </a>

                                    </li>

                                </if>
                                </foreach>
                                <li>
                                    <a href="#" id="checkall">查看所有通知</a>
                                </li>
                            </ul>
                        </li>
                        <!-- notification dropdown end -->
                    </ul>
                    <!--  顶部提示信息 S -->
                </div>
                <script>
                    $(function(){
                        var imt = 0;
                        var iml = 0;
                        var popdiv_w;
                        // 每天信息绑定单击,发送ajax,改该条状态->移动->ajax添加一条
                        $('.check_i').live('click',function(e){

                            // 鼠标单击位置
                            var cx = e.clientX;
                            var cy = e.clientY;
                            // var popdiv_w = $('#popdiv').width();
                            popdiv_w = 300;
                            // 弹出审查信息的水平位置
                            var lf = $(window).width()-popdiv_w-15;

                            // 获得该条c_id
                            var c_id = $(this).attr('cid');
                            var check_i = $(this);

                            $.ajax({
                                url : 'changeChe',
                                data : {c_id:c_id,if_read:0},
                                dataType : 'json',
                                type : 'post',
                                async : false,
                                success : function(data){
                                    console.log(data);
                                    if (data!='0') {
                                        // 成功, 弹出的动作
                                        $('#popdiv').css({'width':'0px','height':'0px','left':cx+'px','top':cy+'px'}).show().animate({'top':'-='+75,'left':lf+'px','width':'300px','height':'150px'},'slow','easeOutBounce');

                                        var popertitle = data['cont_type']=='1'?'信息警告通知':'图片警告通知';
                                        var ptype = data['cont_type']=='1'?'信息':'图片';
                                        $('.popover-t').html(popertitle);
                                        var popercontent = '尊敬的<?php echo $_SESSION['home']['uname'] ?>'+': 你在'+data['public_time']+'发布的'+ptype+'不合法, 已被系统删除...'
                                        $('.popover-c').html(popercontent);

                                        check_i.hide('fast', function(){
                                            $(this).parent().remove();
                                        })

                                        var chknum = $('#chknum').html()-1
                                        $('#chknum').html(chknum);

                                        if (chknum == 0) {
                                            $('#tchknum').html('');
                                        }else {
                                            $('#tchknum').html(chknum);
                                        }

                                        $.ajax({
                                            url : 'getOneCheck',
                                            data : {},
                                            dataType : 'json',
                                            type : 'post',
                                            async : true,
                                            success : function(data){
                                                if (data) {
                                                    var obj = $(data)
                                                    $('#checkall').parent().before(obj);
                                                    obj.show(500,'easeInBounce');
                                                };
                                            }
                                        });

                                    };
                                }
                            });

                            // 查看所有审查信息的位置
                            var imm = $('#checkall').offset()
                            imt = imm.top-25;
                            // alert(imt)
                            iml = imm.left+230;
                            // alert(iml)

                            return false;
                        })

                        // 点击弹出的信息, 消失
                        $('#popdiv').live('click',function(){
                            $(this).animate({'top':imt,'left':iml,'width':'0px','height':'0px'},'slow','swing')
                            return false;
                        })

                        // 单击查看审查所有信息
                        $('#checkall').click(function(){
                            $('#header_notification_bar').toggleClass('open')
                            var spage = $('#checksel').val();
                            // alert(spage)
                            $.ajax({
                                url : 'checkAjax',
                                data : {spage:spage},
                                dataType : 'json',
                                type : 'post',
                                success : function(data){
                                    if (data) {
                                        var str = '<tr class=""><th class="inbox-small-cells">状态</th><th class="view-message dont-show">类型</th><th class="view-message">详情</th><th class="view-message text-right">时间<span class="closeX pull-right">[ X ]</span></th></tr>';
                                        $('#checkdetail').empty().append(str).append(data).parent().show();
                                    }else{

                                    };
                                }
                            })

                            return false;
                        })

                        // 单击查看审查所有信息表格的下拉框选择页码
                        $('#checksel').change(function(){
                            $('#checkall').trigger('click');
                        });

                        // 单击所有审查信息表格的每行, 状态的变化
                        $('.checktr').live('click', function(){
                            var if_read = '';
                            var cstat = $(this).find('.icon-location-arrow').css('color');
                            // rgb(247, 138, 9)
                            if (cstat == 'rgb(213, 213, 213)') {
                                if_read = 1;
                                cstat = 'rgb(247, 138, 9)';
                            }else{
                                if_read = 0;
                                cstat = 'rgb(213, 213, 213)';
                            };

                            var checktr = $(this);
                            var sid = $(this).attr('sid');
                            $.ajax({
                                url : 'changeCheck',
                                data : {if_read:if_read, c_id:sid},
                                dataType : 'json',
                                type : 'post',
                                success  : function(data){
                                    if (data=='1') {
                                        checktr.find('.icon-location-arrow').css('color',cstat);
                                    };
                                }

                            })
                        })

                        // 关闭查看所有审查信息表格
                        $('.closeX').live('click', function(){
                            $('#checkdetail').parent().hide();
                            location.reload();
                        })
                    })

                </script>


                <!-- ↓↓信息审核通知弹框  -->
                <div id="popdiv" style="display:none;width:300px;height:130px;position:absolute;top:230px;left:480px;background:#979797;z-index:10000;border-radius:2%">
                    <h3 class="popover-t"></h3>
                    <div class="popover-c"></div>
                </div>
                <!-- ↑↑信息审核通知弹框 -->
                <!-- ↓↓查看所有审核信息 -->
                <div style="position:absolute;top:100px;left:230px;z-index:10001;width:900px;background:#eee;display:none;">

                    <table class="table table-inbox table-hover"  id="checkdetail" >
                        <tr class="">
                            <th class="inbox-small-cells">状态</th>
                            <th class="view-message dont-show">类型</th>
                            <th class="view-message">详情</th>
                            <th class="view-message text-right">时间</th>
                        </tr>

                    </table>
                    <div class="form-group" style="margin-top:5px;">
                        <div class="col-md-2 pull-right">
                            <select class="form-control " style="margin-bottom:5px;" id="checksel">
                                <?php if ($spageall>=1): ?>
                                    <?php
                                    for ($i=1; $i <= $spageall; $i++) {
                                ?>

                                        <option value="<?php echo $i ?>" ><?php echo $i ?></option>
                                <?php   } ?>
                                <?php endif ?>

                            </select>
                        </div>
                    </div>
                </div>
                <!-- ↑↑查看所有审核信息 -->

                <div class="top-nav " >
                    <!--搜索框 + 管理员设置 S-->
                    <ul class="nav pull-right top-menu">
                        <li id="searchli" style="display:none">
                            <input style="font-size:12px;margin-top:0px" type="text" class="form-control search pull-left" placeholder="用户名">
                            <button class="btnforsearch btn btn-default pull-right " style="margin:0 0 0 10px">搜索</button>
                        </li>
                        <!-- user login dropdown start-->
                        <li class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <img src="__PUBLIC__<?php echo $_SESSION['home']['photo']; ?>
                                " style='width:20px;height:20px;border-radius: 50%'>
                                <!-- 用户/管理员图片 -->
                                <span class="username">
                                    <?php echo $_SESSION['home']['nickname'] ?></span> <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu extended logout">
                                <div class="log-arrow-up"></div>
                                <li>
                                    <a href="{:U('Home/User/index')}">
                                        <i class=" icon-suitcase"></i>
                                        个人中心
                                    </a>
                                </li>
                                <li>
                                    <a href="{:U('Home/News/index')}">
                                        <i class="icon-cog"></i>
                                        发布动态
                                    </a>
                                </li>
                                <li>
                                    <a href="{:U('Home/Login/repwd')}">
                                        <i class="icon-bell-alt"></i>
                                        重置密码
                                    </a>
                                </li>
                                <li>
                                    <a href="{:U('Login/signout')}">
                                        <i class="icon-key"></i>
                                        登出
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a class="btn btn-default" id="btn-chat" href="javascript:void(0);">
                                <i class="icon-comments"></i>
                                会话
                            </a>
                        </li>
                        <!-- user login dropdown end -->
                    </ul>
                    <!--搜索框 + 管理员设置 E-->
                </div>
            </header>
            <!--顶部 E-->

            <!--左侧导航栏 S-->
            <aside>
                <div id="sidebar"  class="nav-collapse ">
                    <!-- sidebar menu start-->
                    <ul class="sidebar-menu">

                        <li class="sub-menu">
                            <a href="javascript:;" class="">
                                <i class="icon-cogs"></i>
                                <span>动态</span>
                                <span class="arrow"></span>
                            </a>
                            <ul class="sub">
                                <li>
                                    <a class="" href="{:U('News/index')}">动态广场</a>
                                </li>
                            </ul>
                        </li>

                        <li class="sub-menu">
                            <a href="javascript:;" class="">
                                <i class="icon-dashboard"></i>
                                <span>用户信息</span>
                                <span class="arrow"></span>
                            </a>
                            <ul class="sub">
                                <li>
                                    <a class="" href="{:U('User/index')}">个人资料</a>
                                </li>
                                <li>
                                    <a class="" href="{:U('User/edit')}">编辑信息</a>
                                </li>
                            </ul>
                        </li>

                        <li class="sub-menu">
                            <a href="javascript:;" class="">
                                <i class="icon-book"></i>
                                <span>好友圈</span>
                                <div id="friend-request"></div>
                                <span class="arrow"></span>
                            </a>
                            <ul class="sub">
                                <li>
                                    <a class="" href="{:U('Friend/index')}">好友管理</a>
                                </li>
                                <li>
                                    <a class="" href="{:U('Friend/request')}">好友请求</a>
                                </li>
                                <li>
                                    <a class="" href="{:U('Friend/ring')}">好友广场</a>
                                </li>
                            </ul>
                        </li>

                        <li class="sub-menu">
                            <a href="javascript:;" class="">
                                <i class="icon-tasks"></i>
                                <span>图片中心</span>
                                <span class="arrow"></span>
                            </a>
                            <ul class="sub">
                                <li>
                                    <a class="" href="{:U('Photo/index')}">图片乐分享</a>
                                </li>
                                <li>
                                    <a class="" href="{:U('Image/index')}">相册</a>
                                </li>
                            </ul>
                        </li>
                        <li class="sub-menu">
                            <a href="javascript:;" class="">
                                <i class="icon-tasks"></i>
                                <span>会员中心</span>
                                <span class="arrow"></span>
                            </a>
                            <ul class="sub">
                                <li><a class="" href="{:U('Vip/index')}">会员中心</a></li>
                                <li><a class="" href="{:U('Vip/show')}">会员特权</a></li>
                            </ul>
                        </li>
                    </ul>
                    <!-- sidebar menu end-->
                </div>
            </aside>
            <!--左侧导航栏 E-->

            <!--右侧主体显示 S-->
            <section id="main-content">
                <section class="wrapper">
                    <!-- 需要填充右侧内容 请使用contents块 -->
                    <block name='contents'></block>
                </section>
                <!-- END -->
            </section>
            <!--右侧主体显示 E-->

        </section>
    </block>
    <!-- 为登录页面准备的块标签 E -->

    <!-- 提示框 S -->
    <div class="alertstr" style="position:relative;z-index:10000">
        <div id="somedialog" class="dialog">
            <div class="dialog__overlay"></div>
            <div class="dialog__content">
                <h2 class="htmlstr"></h2>
                <div>
                    <button class="action btn btn-default" data-dialog-close>关闭</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 提示框 E -->

    <!-- js placed at the end of the document so the pages load faster -->

    <script src="__PUBLIC__/Theme/js/bootstrap.min.js"></script>
    <script src="__PUBLIC__/Theme/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/Theme/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Theme/js/jquery.sparkline.js" type="text/javascript"></script>
    <script src="__PUBLIC__/Theme/assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script>
    <script src="__PUBLIC__/Theme/js/owl.carousel.js" ></script>
    <script src="__PUBLIC__/Theme/js/jquery.customSelect.min.js" ></script>

    <script src="__PUBLIC__/Theme/assets/gritter/js/jquery.gritter.js"></script>


    <!--common script for all pages-->
    <script src="__PUBLIC__/Theme/js/common-scripts.js"></script>
    <script src="__PUBLIC__/Theme/js/jquery.stepy.js"></script>
    <!--script for this page-->
    <script src="__PUBLIC__/Theme/js/sparkline-chart.js"></script>
    <script src="__PUBLIC__/Theme/js/easy-pie-chart.js"></script>
    <script src="__PUBLIC__/Theme/js/easing.js"></script>

    <!-- ajax返回状态用js -->
    <script src="__PUBLIC__/Alert/js/classie.js"></script>
    <script src="__PUBLIC__/Alert/js/dialogFx.js"></script>
    <!-- 后台模版用js -->
    <script>
        $(document).ready(function() {
          $("#owl-demo").owlCarousel({
              navigation : true,
              slideSpeed : 300,
              paginationSpeed : 400,
              singleItem : true

          });
          $('select.styled').customSelect();
        });
    </script>
    <!-- 瀑布流用放大效果 -->
    <block name='bigimg'></block>
    <!-- ajax返回状态  显示提示用 -->
    <block name='pdajax'>
        <script>
                  (function() {
                        var alertstr = document.getElementsByClassName('alertstr')[0];
                        var dlgtrigger = document.querySelector( '[data-dialog]' ),
                        somedialog = document.getElementById( dlgtrigger.getAttribute( 'data-dialog' ) ),
                        dlg = new DialogFx( somedialog );

                        $('.trigger').live('click',dlg.toggle.bind(dlg));

                        $('.trigger').live('click',function(){
                              $.post("{$ajaxurl}",{pd:pd},function(data){
                                if (data =='yes') {
                                      $('.htmlstr').html('{$yesstr}');
                                      // console.log('yes');
                                }else if(data =='no'){
                                      $('.htmlstr').html('{$nostr}');
    /*                                  console.log('no');*/
                                }
                              });
                        });

                  })();

    </script>

        <!-- 判断下线 S -->
        <script type="text/javascript"></script>
        <!-- 判断下线 D -->

    </block>
</body>
</html>
